package com.hoopchina.ui.main;

import com.hoopchina.news.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
/**
 * RefreshTip
 * 刷新动画view
 * 
 *@author Neusoft
 */
public class RefreshTip extends UIWidget {
	private TextView mTxtTip;
	private Animation mAnimationTip;

	public RefreshTip(Context context) {
		super(context);
	}
	
	public RefreshTip(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	/*
	 * 加载本地资源
	 * @see com.hoopchina.ui.main.UIWidget#loadResources()
	 */
	@Override
	protected void loadResources() {
		LayoutInflater inflater = 
			( LayoutInflater )getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
		inflater.inflate( R.layout.refreshtip, this, true );
		mTxtTip=(TextView) findViewById(R.id.txtRefeshTip);
		System.out.println(">>>>>>>>>>>>>>loadResources<<<<<<<<<<<<<");
	}
	/*
	 * 对动画上的文字进行设置
	 */
	public void setText(String aText){
		mTxtTip.setText(aText);
	}
    /*
     * 开始动画并对动画过程进行监听
     */
	public void startClosing(){
		mAnimationTip=AnimationUtils.loadAnimation(getContext(), R.anim.alphatip);
		mAnimationTip.setAnimationListener( new AnimationListener() {

			public void onAnimationStart(Animation animation) {
				
				
			}
			//当动画结束时
			public void onAnimationEnd(Animation animation) {
				RefreshTip.this.setVisibility(View.INVISIBLE);
				
			}

			public void onAnimationRepeat(Animation animation) {
				// TODO Auto-generated method stub
				
			}
		
		});
		this.startAnimation(mAnimationTip);
	}

}
